# -*- coding: utf-8 -*-
# @Time    : 2020/9/24 下午4:36
# @Author  : lilong

from rasa.cli.utils import print_warning
from rasa.constants import DOCS_BASE_URL
from rasa.core.lock_store import LockStore

import rasa.core.run
import rasa.nlu.run
from rasa.core.utils import AvailableEndpoints
import rasa.utils.common as utils


endpoints = "endpoints.yml"
credentials = "credentials.yml"
connector = None
log_file = "log.txt"
cors = "*"
port = 5002
model = "../bot_playground/bot_tiny/models/nlu_core"

_endpoints = AvailableEndpoints.read_endpoints(endpoints)

if not connector and not credentials:
    connector = "rest"
    print_warning(
        "No chat connector configured, falling back to the "
        "REST input channel. To connect your bot to another channel, "
        "read the docs here: {}/user-guide/"
        "messaging-and-voice-channels".format(DOCS_BASE_URL)
    )

# 运行core的服务器
rasa.core.run.serve_application(
    model,
    cors=cors,
    port=port,
    channel=connector,
    credentials=credentials,
    endpoints=_endpoints,
    log_file=log_file
)
